//
//package com.initialize.pub.controller;
//
//import com.initialize.pub.exception.SignException;
//import com.initialize.pub.exception.TokenException;
//import com.initialize.pub.pojo.Result;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.web.bind.annotation.ControllerAdvice;
//import org.springframework.web.bind.annotation.CrossOrigin;
//import org.springframework.web.bind.annotation.ExceptionHandler;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.servlet.http.HttpServletRequest;
//import java.util.LinkedHashMap;
//import java.util.Map;
//
///**
// * 全局异常处理
// */
//@CrossOrigin
//@ControllerAdvice
//@RestController
//public class GlobalExceptionHandler {
//    private Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
//
//    @ExceptionHandler(value = Exception.class)
//    public Result defaultErrorHandler(HttpServletRequest req, Exception e) {
//        Result result = new Result();
//        result.setStatus_code(101);
//        Map<String, Object> map = new LinkedHashMap<>();
//        map.put("Exception", "administrator-can-view");
//        map.put("RequestURL", req.getRequestURL());
//        result.setResult(map);
//        logger.error("Exception###{}", e.getMessage());
//        logger.error("RequestURL###{}", req.getRequestURL());
//
//        return result;
//    }
//
//    @ExceptionHandler(value = SignException.class)
//    public Result signErrorHandler(HttpServletRequest req, Exception e) {
//        Map<String, Object> map = new LinkedHashMap<>();
//        map.put("Exception", "illegal-sign");
//        map.put("RequestURL", req.getRequestURL());
//        logger.error("Exception###{}", e);
//        logger.error("RequestURL###{}", req.getRequestURL());
//        return new Result(102, map);
//    }
//
//    @ExceptionHandler(value = TokenException.class)
//    public Result tokenErrorHandler(HttpServletRequest req, Exception e) {
//        Map<String, Object> map = new LinkedHashMap<>();
//        map.put("Exception", "illegal-token");
//        map.put("RequestURL", req.getRequestURL());
//        logger.error("Exception###{}", e.getMessage());
//        logger.error("RequestURL###{}", req.getRequestURL());
//        return new Result(102, map);
//    }
//
//}